<?php
namespace app\controller\api\cms;
use app\FrontendController;
use app\model\cms\ArticleModel;
use app\model\tool\ImageModel;

class Article extends FrontendController
{

    /**
     * 该文章信息
     */
    public function single( $id )
    {

        
        $res = [
            'code'=>0
        ];
        if( !$id ){
            $res['code'] = 1;
            $res['message'] = '参数不合法';
        }
        $res['article'] = ArticleModel::where( 'id', $id )->find( );


        $res['article']->content = html_entity_decode( $res['article']->content );

        $res['article']->image = ImageModel::resize2( $res['article']->image, 350,350 );

        if( !empty( $res['article']->custom  )  ){
            $res['article']->custom = json_decode( $res['article']->custom, true );
        }else{
            $res['article']->custom = [];
        }

        return json( $res );

    }

}